package com.xxx.greneric;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @version v1.0
 * @Description
 * @Author admin
 * @date 2021/7/21  10:52
 * @Copyright
 */
public class GenericDome01 {
    public static void main(String[] args) {
        //m1();
        ArrayList<String> arrayList = new ArrayList<>();//底层是数组结构，比较适用于查询，不适于增与删
        arrayList.add("a");
        arrayList.add("b");
       // arrayList.add(1);//自动装箱，new integer
        arrayList.add("b");
        arrayList.add("b");


//        Iterator iterator = arrayList.iterator();
        Iterator<String> iterator = arrayList.iterator();
        while (iterator.hasNext()){
//            String s = (String) iterator.next();
            String s = iterator.next();
            System.out.println("s = " + s);
        }

    }

    private static void m1() {
        ArrayList arrayList = new ArrayList();//底层是数组结构，比较适用于查询，不适于增与删
        arrayList.add("a");
        arrayList.add("b");
        arrayList.add(1);//自动装箱，new integer
        arrayList.add("b");
        arrayList.add("b");


        Iterator iterator = arrayList.iterator();
        while (iterator.hasNext()){
            String s = (String) iterator.next();
            System.out.println("s = " + s);
        }
    }
}
